package leetcode.code0788;

import leetcode.IDebug;
import leetcode.helper.H;

public class Solution implements IDebug {

	public int rotatedDigits(int n) {
		int ans = 0;
		for (int i = 2; i <= n; i++) {
			int num = i;
			int cur = 0;
			int pos = 1;
			while (num > 0) {
				int last = num % 10;
				if (last == 3 || last == 4 || last == 7) {
					cur = i;
					break;
				}
				if (last == 2) {
					last = 5;
				} else if (last == 5) {
					last = 2;
				} else if (last == 6) {
					last = 9;
				} else if (last == 9) {
					last = 6;
				}
				cur += last * pos;
				pos *= 10;
				num /= 10;
			}
			if (cur != i) {
				ans += 1;
			}

		}
		return ans;
	}

	@Override
	public void debug4() {
		H.compare(4, this.rotatedDigits(10));

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
